module SinatraDemo
  module Helpers
    require 'app/helpers/artist'
    require 'app/helpers/album'
    def base64_image(filename, content)
      extname = File.extname filename
      mime_type = Rack::Mime.mime_type extname
      encoded = Base64.encode64(content)
      "data:#{mime_type};base64,#{encoded}".html_safe
    end
    def md_render
      Redcarpet::Markdown.new(Redcarpet::Render::HTML)
    end
    def html(html)
      @html ||= begin
        md_render.render(html)
      end
    end
    include ArtistHelper
    include AlbumHelper
  end
end